package com.sunfield.baseframe.http;

/**
 * Created by wangxl on 2016/10/25.
 */
public class HttpResult {
    /**
     * 请求路径
     */
    String httpUrl;
    /**
     * 返回的json
     */
    String json;
    /**
     * 错误信息
     */
    String message;
    /**
     * 操作控制参数
     */
    int configKey;
    /**
     * 是否请求成功
     */
    boolean isSuccess;
    /**
     * 状态码
     */
    String statusCode;
    /**
     * 请求时传人用于回调的其他参数
     */
    Object otherForCallback;
    /**
     * 请求使用的Client类名
     */
    String clientClassName;
    /**
     * 请求的方法名
     */
    String clientMethodName;

    public HttpResult(String httpUrl, String json, String message, int configKey, boolean isSuccess, String statusCode, Object otherForCallback, String clientClassName, String clientMethodName) {
        this.httpUrl = httpUrl;
        this.json = json;
        this.message = message;
        this.configKey = configKey;
        this.isSuccess = isSuccess;
        this.statusCode = statusCode;
        this.otherForCallback = otherForCallback;
        this.clientClassName = clientClassName;
        this.clientMethodName = clientMethodName;
    }

    public String getHttpUrl() {
        return httpUrl;
    }

    public String getJson() {
        return json;
    }

    public String getMessage() {
        return message;
    }

    public int getConfigKey() {
        return configKey;
    }

    public boolean isSuccess() {
        return isSuccess;
    }

    public String getStatusCode() {
        return statusCode;
    }

    public Object getOtherForCallback() {
        return otherForCallback;
    }

    public boolean match(BaseHttpClient client, String methodName){
        if(client == null || methodName == null){
            return false;
        }
        return client.getClass().getName().equals(clientClassName) && methodName.equals(clientMethodName);
    }

    public boolean match(Class clientClass, String methodName){
        if(clientClass == null || methodName == null){
            return false;
        }
        return clientClass.getName().equals(clientClassName) && methodName.equals(clientMethodName);
    }
}
